package com.zuxia.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zuxia.dto.OrderToDto;
import com.zuxia.entity.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zuxia.param.OrderOnePageParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author laoli
 * @since 2024-11-18
 */
@Mapper
public interface OrderMapper extends BaseMapper<Order> {
    @Select("SELECT * from `order` where;")
    IPage<Order> getPage()throws Exception;

@Select("SELECT \n" +
        "    orders.*, \n" +
        "    `order`.* \n" +
        "FROM \n" +
        "    `order` \n" +
        "RIGHT  JOIN \n" +
        "    orders ON orders.order_id = `order`.order_id where `order`.order_status=#{param.status}")


IPage<OrderToDto> getOrderPage(Page page, @Param("param") OrderOnePageParam param)throws Exception;
    @Select("SELECT \n" +
            "    orders.*, \n" +
            "    `order`.* \n" +
            "FROM \n" +
            "    `order` \n" +
            "RIGHT  JOIN \n" +
            "    orders ON orders.order_id = `order`.order_id ")
    List<OrderToDto> getPageOder()throws Exception;

    @Select("select * from `order` a right join orders b on a.order_id=b.order_id where b.orders_id=#{ordersId}")
    OrderToDto getOrderOnOrdersById(@Param("ordersId") String ordersId);
}
